// pages/my/vip/vipCard_detail2/index.js
const app=getApp();
const getVipDetail2=require("../../../controllers/ControllerVip").controller.getVipDetail2;
const receive=require("../../../controllers/ControllerVip").controller.receive;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    globalStype:'',
    value:{
      vipId:'',
      shopId:''
    },
    detail_list:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({globalStype:app.globalData.globalStype})
    if(options.id){
      let id=options.id;
      this.setData({
        'value.vipId':id
      })
      this.getCardDetail();
    }
    if(options.scene){
      let scene=decodeURIComponent(options.scene);
      console.log(scene);
      let vipId=scene.split(",")[0].split(":")[1];
      let shopId=scene.split(",")[1].split(":")[1];
      wx.setStorageSync('shopId', shopId);
      app.globalData.shopId=shopId
      this.setData({
        shopId:shopId,
        'value.vipId':vipId
      })
      this.getCardDetail();
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  //获取会员卡详情
  getCardDetail(){
    this.setData({
      'value.shopId':app.globalData.shopId
    })
    getVipDetail2(this.data.value).then(res=>{
      this.setData({
        detail_list:res.data.goods
      })
      console.log(this.data.detail_list)
    })
  }
})